package java_thinking.unit_17._17_7_8;

import java_thinking.unit_17._17_2_6.CountingMapData;

import java.util.Iterator;
import java.util.TreeMap;

/**
 * @Desc:
 * @author: cww
 * @DateTime: 2019-04-17 22:15
 */

public class SortedMapDemo {
    public static void main(String[] args) {
        TreeMap<Integer,String> sortedMap = new TreeMap<>(new CountingMapData(10));
        System.out.println(sortedMap);
        Integer low = sortedMap.firstKey();
        Integer high = sortedMap.lastKey();
        System.out.println("low :" + low);
        System.out.println("high :" + high);
        Iterator<Integer> iterator = sortedMap.keySet().iterator();
        for (int i = 0; i <= 6; i++) {
            if (i == 3) low = iterator.next();
            if (i == 6) high = iterator.next();
            else iterator.next();
        }
        System.out.println("low :" + low);
        System.out.println("high :" + high);
        System.out.println(sortedMap.subMap(low,high));
        System.out.println(sortedMap.headMap(high));
        System.out.println(sortedMap.tailMap(low));
    }
}
